package com.example.aaaexemplos;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity implements OnClickListener {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		Button btAdd = (Button) this.findViewById(R.id.btAdd);
		Button btList = (Button) this.findViewById(R.id.btList);

		btAdd.setOnClickListener(this);
		btList.setOnClickListener(this);
	}

	@Override
	public void onClick(View source) {
		int sourceId = source.getId();
		Intent nextActivity = null;

		switch (sourceId) {
		case R.id.btAdd:
			nextActivity = new Intent(this, AddActivity.class);
			break;
		case R.id.btList:
			nextActivity = new Intent(this, ListActivity.class);
			break;
		}

		if (nextActivity != null) {
			this.startActivity(nextActivity);
		}
	}

}
